Repository navigation
refactor(chat): colocate leaf chat helpers under loopx.chat and ratchet module budget (#5072) - #9179
loopx-agent wants to merge 1 commit into
Conversation
loopx-agent
left a comment
There was a problem hiding this comment.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
Reviewer: model_agent · Antigravity · Google Deepmind · self_reported
动机 / Motivation
在 loopx/ 顶层目录中,面向个人工作区与受管 chat 通道的内部叶子模块(loopx/chat_operator_provider_api.py、loopx/chat_attachments.py、loopx/chat_dsh.py)此前仍平铺在包根目录下,使 loopx/*.py 顶层模块总数停留在 124 个。对于需要按目录划定 CODEOWNERS 与推进 loopx-core / loopx-workspace 拆分(#5072)的贡献者和维护者而言,这种平铺结构让私有/内部 chat 辅助模块与 quota.py、todos.py 等核心内核入口混在一起,阻碍模块归属清晰化并使顶层模块预算停滞。
迁移前后的核心变化如下:迁移前 loopx/ 顶层包含 124 个 .py 模块且 3 个内部 chat 叶子模块平铺在包根目录,而迁移后 3 个模块归位到 loopx/chat/ 且零永久顶层 shim,顶层模块数降至 121 个。可验证的结果是:loopx/*.py 数量从 124 降为 121,test_top_level_module_budget.py 与 test_chat_internal_module_layout.py 通过且所有调用方保持原有行为不变。本 PR 不修改任何公开 API 语义、协议 schema、运行期权限边界或默认行为。作为 #5072 M1 的一个独立可回滚批次,其余尚未迁移的顶层 chat_* 与 *_goal_mode 模块仍待后续 M1/M2 PR 推进。
改动思路 / Approach
| 变更维度 | 迁移前(64353773dc) |
迁移后(149a7ed12b) |
约束 / 收益 |
|---|---|---|---|
| 模块落点 | loopx/chat_{operator_provider_api,attachments,dsh}.py |
loopx/chat/{operator_provider_api,attachments,dsh}.py |
复用 loopx/chat.py 的 __path__ 命名空间包,无 __init__.py |
| 相对导入深度 | 同级 .control_plane / .chat / .chat_agent |
子包内 ..control_plane / ..chat / ..chat_agent |
保持原有导入图与延迟加载时机不变 |
| 兼容桥接 | 顶层文件直接存在 | 无永久顶层 shim(I3 内部迁移直接删除旧入口) | importlib.util.find_spec 确认旧模块不再解析 |
| 预算棘轮 | max_top_level_modules: 124 |
max_top_level_modules: 121(baseline 更新至 64353773dc) |
由 test_top_level_module_budget.py 强制锁定只降不升 |
整体架构复用既有模式:入口与调用边界维持在 loopx/presentation/configuration_api.py、loopx/presentation/codex_attached_api.py、loopx/chat_server.py、loopx/chat_runtime.py、loopx/chat_ingress.py、loopx/chat_agent.py、loopx/extensions/lark/ 与 loopx/capabilities/native_chat/,没有任何第二份配置或重复状态。在架构归属与职责边界上,本次迁移纯属既有 loopx.chat 命名空间下的目录归位且零新增运行期机制,完整保留了原有 provider IO 与策略边界的归属不变。当前 PR 的边界严格限定为迁入这 3 个内部 chat 叶子模块、同步全部调用方与测试和 smoke 及成对 RFC 引用、补充无 shim 断言并把顶层预算从 124 收紧至 121,其余顶层模块留待后续切片。
正向走读:ChatConfigurationRequestMixin 通过 from ..chat import operator_provider_api 挂载 /api/chat/operator-credential;ChatRuntimeController 与 builtin_chat_endpoints 从 loopx/chat/dsh.py 读取 DshChatAdapter 与 STEWARD_SEGMENT_ENV;HTTP、Lark、Codex/Antigravity adapter 从 loopx/chat/attachments.py 导入附件大小与格式校验函数。反向与架构守卫:tests/test_chat_internal_module_layout.py 显式验证三个新模块 __module__ 均位于 loopx.chat.* 下,且旧顶层模块 importlib.util.find_spec("loopx.chat_*") 返回 None。
具体改动 / Changes
依据规范 docs/architecture/rfcs/monorepo-distribution-split-v0.md(基线修订 64353773dc8b1ca82ff531cc7653dec6c3d41c0b),各条验收准则在本 exact head(149a7ed12ba92bf7737004263abba17e8ff029bc)的核对映射如下:
| Criterion ID | 规范条款 | Disposition | 验证路径 / 命令 |
|---|---|---|---|
M1-LEAF-MOVE |
M1 将内部 loopx/chat_* 迁入 loopx/chat/ 并更新内部相对导入与调用方 |
implemented |
loopx/chat/{operator_provider_api,attachments,dsh}.py;pytest -q tests/test_chat_internal_module_layout.py |
I3-NO-SHIM |
纯内部迁移同步更新所有活跃调用方并删除旧顶层入口,不保留永久兼容 shim | implemented |
全仓 rg -n 零残留引用;tests/test_chat_internal_module_layout.py 校验 find_spec 为 None |
SEC9-BUDGET |
同 PR 下调 tests/architecture/top_level_module_budget.json 的 max_top_level_modules |
implemented |
tests/architecture/top_level_module_budget.json(124 → 121);pytest -q tests/architecture/test_top_level_module_budget.py |
RFC-BILINGUAL-SYNC |
同步更新受影响的中英文成对 RFC 文档路径并保持双语一致性 | implemented |
docs/architecture/rfcs/harness-selection-dsh-pi-v0.{md,zh-CN.md};scripts/check_rfc_bilingual.py --base origin/main --head HEAD |
全量 diff 共 32 个文件(+48 / -39 行):3 个 git mv 重命名及内部相对导入深度调整(from .foo → from ..foo)、21 个内部代码/测试/smoke 调用路径更新、1 组对称中英文 RFC 路径更新(loopx/chat_dsh.py → loopx/chat/dsh.py)、1 个布局测试新增 3 项校验与无 shim 断言,以及 tests/architecture/top_level_module_budget.json 预算下调。
关键代码讲解
loopx/chat/operator_provider_api.py(OperatorProviderRequestMixin):原顶层模块通过from .control_plane.operator_provider import ...读取凭据投影与写入方法;迁入loopx/chat/后改为from ..control_plane.operator_provider import ...,而loopx/presentation/configuration_api.py改为from ..chat import operator_provider_api as operator_api。实际路由/api/chat/operator-credential、只写不回显的密钥约束与异常错误码(400 invalid_operator_credential、500 operator_credential_write_failed)均原样保留。loopx/chat/dsh.py(DshChatAdapter、STEWARD_SEGMENT_ENV):迁入子包后将 4 处顶层相对导入(.chat、.chat_agent、.control_plane.turn_driver.host_binding、.dsh_goal_mode.turn_host_adapter)全部调整为..父级包导入,确保在loopx/chat.py通过__path__暴露的子包结构中正确绑定parse_agent_response、CodexChatAgentError、dsh_output_token_budget与run_dsh_turn;单 executor 槽位锁与DSH_PERMISSION_MODE="read-only"沙箱固定逻辑保持一致。loopx/chat/attachments.py(normalize_chat_attachments、require_text_document_route):纯标准库实现,无内部相对导入;迁入loopx/chat/后由loopx/chat_server.py、loopx/chat_ingress.py、loopx/chat_runtime.py、loopx/chat_agent.py、loopx/chat/result_files_api.py(同级改为from .attachments import ...)、loopx/presentation/codex_attached_api.py、loopx/extensions/lark/与loopx/capabilities/native_chat/统一导入,继续执行图片 4 张 / 单张 5MB / 总计 12MB 与本地受管 Codex 文本文档路由限制。loopx/chat/endpoint_catalog.py(managed_host_capability):将from ..chat_dsh import STEWARD_SEGMENT_ENV调整为同级导入from .dsh import STEWARD_SEGMENT_ENV,使内置端点目录返回的sandbox_mode与实际执行片段环境变量保持单一事实源。
对主干的风险 / Risks
- 未发现阻断性回归风险(No blocking findings):全仓通过
rg -n "chat_operator_provider_api|chat_attachments|chat_dsh"扫描loopx/、tests/、examples/、apps/、packages/、scripts/、docs/,除tests/test_chat_internal_module_layout.py中有意检查importlib.util.find_spec返回None的负向断言外,零残留旧模块引用;ls -1 loopx/*.py | wc -l实测精确等于121。 - 调用方与负向边界验证:
- 架构与核心单元测试:
uv run --extra test python -m pytest -q tests/architecture/test_top_level_module_budget.py tests/architecture/test_control_plane_import_boundaries.py tests/architecture/test_package_kernel_import_ratchet.py tests/test_chat_image_attachments.py tests/test_chat_image_http.py tests/test_chat_dsh_adapter.py tests/test_chat_endpoint_readiness.py tests/test_chat_executor_profile.py tests/test_atomic_write_modes.py tests/test_chat_reasoning_selection.py tests/control_plane/test_goal_activation.py tests/test_chat_internal_module_layout.py tests/test_audit_cli_and_runtime_fixes.py tests/test_manager_context_roundtrip.py→ PASS(340 passed in 127.91s),覆盖预算棘轮、无 shim 负向断言、附件超限拒绝、DSH 并发执行器拒绝与超时错误路径。 - 下游调用方测试:
uv run --extra test python -m pytest -q tests/test_lark_private_images.py tests/test_lark_app_image_projection.py tests/test_lark_post_images.py tests/test_chat_file_discovery.py tests/test_chat_machine_configuration_api.py tests/test_chat_transport_composition.py tests/test_chat_agent.py tests/test_chat_server_cors.py tests/test_chat_startup_isolation.py tests/test_lark_private_conversations.py→ PASS(1288 passed in 823.36s)。 - 静态与双语校验:
ruff check(All checks passed!)、mypy(Success: no issues found in 17 source files)、scripts/check_rfc_bilingual.py --base origin/main --head HEAD(RFC bilingual diff check passed.)、loopx check(errors=0)与 Goal 绑定loopx canary premerge --from-git-diff --git-diff-base origin/main --goal-id personal-loopx-maintenance --format json(ok: true,selected=11 failures=0,change_qualityreceiptcqr_c5dce6287469e9a502b9valid)全部 PASS。 - Smoke 与残余风险(Residual risk):
examples/loopx-managed-turn-operator-flow-smoke.py在64353773dc基线与149a7ed12b当前 head 均输出完全一致的 5 项检查 PASS;examples/loopx-steward-managed-chat-smoke.py在当前环境因未安装可选包deepseek-harness-sdk打印skip: deepseek-harness-sdk is not installed并退出0(UNVERIFIED 真实 SDK 链路;DshChatAdapter行为本身已由test_chat_dsh_adapter.py与loopx-managed-turn-operator-flow-smoke.py覆盖)。此外未运行全仓全部 pytest,未咨询远端 CI(wait_for_ci: false)。
- 架构与核心单元测试:
我的整体评价 / Verdict
本次 PR 为 justified_increment:在不引入任何兼容债务与行为漂移的前提下,将 3 个内部 chat 叶子模块干净迁入 loopx/chat/ 并将顶层模块预算从 124 棘轮收紧至 121。
- Long-horizon (
improved):降低平铺模块规模并巩固loopx/chat/目录边界与单向预算棘轮,利于后续 #5072 M1/M2 分包交付与维护边界清晰化。 - User experience (
preserved) / Visual review (not_applicable):纯内部 Python 模块搬迁与 RFC 路径同步,未修改任何渲染界面或前端展示逻辑;已核对loopx/presentation/configuration_api.py与loopx/presentation/codex_attached_api.py仅更新 import 路径(unverified_scope:none)。 - 语义词表与兼容评估:未新增或修改任何状态枚举、协议字面量或配置语义词表(
semantic_alignment:not_applicable);observable_semantics在不可变基线64353773dc与当前 head149a7ed12b的同命令对比下保持完全等价(equivalent)。 - Exact-head freshness:复核远端 head 仍为
149a7ed12ba92bf7737004263abba17e8ff029bc,已通过本地 premerge 与 change-quality 验证。
English verdict: APPROVE at exact head 149a7ed (published as COMMENTED review because PR #9179 is author-owned; 3 M1 internal leaf modules moved to loopx/chat/, all callers/tests/bilingual RFC refs updated with zero permanent shims, top_level_module_budget ratcheted 124 -> 121, 340 + 1288 pytest cases + ruff + mypy + canary premerge PASS; optional deepseek-harness-sdk live step in loopx-steward-managed-chat-smoke.py skipped in local env).
|
This pull request has merge conflicts with Choose the remote for the base repository, not an out-of-date fork. git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEADFor a same-repository clone whose Keep the DCO |
…odule budget Implements the next monorepo-distribution-split-v0 (#5072) M1 internal leaf migration without permanent top-level compatibility shims: - Move loopx/chat_operator_provider_api.py -> loopx/chat/operator_provider_api.py - Move loopx/chat_attachments.py -> loopx/chat/attachments.py - Move loopx/chat_dsh.py -> loopx/chat/dsh.py - Update internal relative imports, callers, tests, smokes, layout guards, and symmetrical RFC references - Ratchet tests/architecture/top_level_module_budget.json from 122 to 119 at baseline db76a91 Signed-off-by: LoopX Agent <[email protected]>
149a7ed to
01bd56d
Compare
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google · self_reported
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
LoopX Chat 运行时(ChatRuntimeController、chat_server、chat_agent、chat_ingress)、Lark 私有图片与会话交付扩展、前端配置 API(presentation/configuration_api、codex_attached_api)以及 loopx-core 与 loopx-workspace 分包维护者。
迁移前(含 149a7ed12b 基线旧提交):loopx/chat_attachments.py、loopx/chat_dsh.py 与 loopx/chat_operator_provider_api.py 仍位于 loopx/ 顶层,且原 PR 分支因主干已先合并 #9056/#8905/#9190 而发生冲突与预算错位;变基到 db76a91f0c 后(精确 head 01bd56d3be):三个内部模块直接迁入 loopx/chat/{attachments,dsh,operator_provider_api}.py,dsh.py 同步对齐主干 #8905 的 _turn_prompt 导入,全仓 32 个文件(含双语 RFC)同步更新并删除旧顶层入口,预算从 122 精确棘轮收紧至 119。
loopx/*.py 顶层模块数实测为 119 且与 top_level_module_budget.json(119)吻合;importlib.util.find_spec 对 loopx.chat_attachments、loopx.chat_dsh 与 loopx.chat_operator_provider_api 均返回 None;附件校验拒收、DSH 沙箱只读环境变量与并发互斥拒绝、Operator 凭据读写及 1630 项定向单元测试均与迁移前等价。
本 PR 不改动附件校验阈值、DSH 单段只读执行契约、Operator 凭据脱敏逻辑或并发 PR #9196 的搬迁文件,也不要求本地环境安装可选 deepseek-harness-sdk。
剩余顶层 chat_*.py 与 *_goal_mode 模块迁移仍在 #5072 后续批次推进;可选依赖 deepseek-harness-sdk 未在本地安装故实跑链路跳过;另主干已推进至 PR #9193(202d7bdb05),本分支处于 BEHIND(无文件冲突)。
改动思路 / Approach
本轮是对 PR #9179 在变基至 db76a91f0cc1afb8b10505a94b0a44cf017aaa69 后的全量精确 head 复审(较此前旧提交 149a7ed12ba92bf7737004263abba17e8ff029bc 的关键更新包括:清除变基冲突、在 loopx/chat/dsh.py 对齐主干 #8905 引入的 from ..chat import _turn_prompt 相对导入、以及将 top_level_module_budget.json 的基线与上限从旧提交的 124→121 更新为当前主干基线 122→119)。依据 docs/architecture/rfcs/monorepo-distribution-split-v0.md @ 16f418837c87ab40f04ff303962598f5bd71a034,PR 采用“纯内部搬迁删除旧模块 + 全仓同步导入 + 英文/中文 RFC 成对更新 + 预算单向收紧”的零债方案。
将仅在内部消费的附件大小与格式校验、DSH 托管片段适配器和 Operator 凭据路由 Mixin 直接归位到 loopx/chat/ 并取消全部顶层兼容 shim,不引入新抽象、开关或兼容桥,同时同步修复双语 RFC 路径并把顶层预算按实际净减少量从 122 降至 119,是符合 M1 与 I3 的最小可逆切分。
当前 PR 边界(current_pr_boundary):本 PR 仅处理 chat_attachments、chat_dsh 与 chat_operator_provider_api 三个已清点叶子模块及其全仓调用方与双语 RFC 引用,保持与并行 PR #9196 搬迁目标完全正交,其余顶层模块留待后续批次。
变基与导入流向对比:
旧 head 149a7ed12b (pre-rebase, budget 124->121) ──[rebase onto db76a91f0c + #8905 _turn_prompt]──▶ 新 head 01bd56d3be528a2b50f8c901fe9407b0681af8c2
loopx/chat_{attachments,dsh,operator_provider_api}.py ──[git mv, 零 shim]──▶ loopx/chat/{attachments,dsh,operator_provider_api}.py (122->119)
具体改动 / Changes
依据规范 docs/architecture/rfcs/monorepo-distribution-split-v0.md(修订 16f418837c87ab40f04ff303962598f5bd71a034)逐条核验:
M1(implemented):loopx/chat_attachments.py、loopx/chat_dsh.py、loopx/chat_operator_provider_api.py通过git mv迁入loopx/chat/,由tests/test_chat_internal_module_layout.py断言其__module__均位于loopx.chat.*。I3(implemented):经核查loopx/__init__.py与loopx/chat.py均未对外重导出这 3 个内部模块;PR 同步更新全部 23 处内部调用方、测试与示例 smoke(含loopx/presentation/、loopx/extensions/lark/、loopx/capabilities/native_chat/与loopx/chat_*.py),且不保留任何顶层兼容 shim;同时成对同步了docs/architecture/rfcs/harness-selection-dsh-pi-v0.md与.zh-CN.md中对loopx/chat/dsh.py的路径引用。Section 9 row 1(implemented):tests/architecture/top_level_module_budget.json将baseline_commit固定为db76a91f0cc1afb8b10505a94b0a44cf017aaa69并将max_top_level_modules从122精确下调至119(实测ls -1 loopx/*.py | wc -l为119)。
关键代码讲解
DshChatAdapter(loopx/chat/dsh.py#L87-L309):负责管家通道的受控单段 DSH 只读执行(固定STEWARD_SEGMENT_ENV = {"DSH_PERMISSION_MODE": "read-only"}与单槽位并发拒绝MANAGED_HOST_CHAT_SEGMENT_IN_FLIGHT)。搬迁与变基后,相对导入精确更新为from ..chat import _turn_prompt, parse_agent_response、from ..chat_agent import ...、from ..control_plane.turn_driver.host_binding import dsh_output_token_budget与from ..dsh_goal_mode.turn_host_adapter import ...,同目录loopx/chat/endpoint_catalog.py#L20改为from .dsh import STEWARD_SEGMENT_ENV,上游loopx/chat_runtime.py#L47改为from .chat.dsh import DshChatAdapter。normalize_chat_image_attachments(loopx/chat/attachments.py#L49-L100):负责对 Chat 图片附件的 base64 编码、MIME 白名单、5MB/12MB大小上限及bool非法整数类型执行严格校验。搬迁后全部内部消费者——包含loopx/chat_agent.py#L1545、loopx/chat_ingress.py#L455、loopx/chat_runtime.py#L423、loopx/chat_server.py#L27、loopx/chat/result_files_api.py#L9、loopx/capabilities/native_chat/*、loopx/extensions/lark/*与loopx/presentation/codex_attached_api.py#L15——均已切换至loopx.chat.attachments。OperatorProviderRequestMixin(loopx/chat/operator_provider_api.py#L35-L110):为个人工作台提供/api/chat/operator-credential的只写凭据更新与脱敏状态读取。搬迁后顶部导入更新为from ..control_plane.operator_provider import ...,消费方loopx/presentation/configuration_api.py#L20改为from ..chat import operator_provider_api as operator_api。ChatRuntimeController.submit_turn(loopx/chat_runtime.py#L405-L426):在入队或提交回合前懒导入from .chat.attachments import require_text_document_route校验文本附件通道授权边界,确保无兼容 shim 情况下入口校验路径保持不变。
对主干的风险 / Risks
- 全仓残留扫描与负向/反事实检查(PASS):在独立干净工作树(重装可编辑
loopx验证loopx.__file__与loopx.chat.__path__指向当前 PR 检出目录后)执行全仓rg -n "\bchat_(attachments|dsh|operator_provider_api)\b",确认除tests/test_chat_internal_module_layout.py负向断言与tests/test_chat_dsh_adapter.py别名外零残留旧引用;Python 负向检查验证importlib.util.find_spec对loopx.chat_attachments、loopx.chat_dsh、loopx.chat_operator_provider_api均返回None,且normalize_chat_image_attachments拒收size: True、normalize_chat_attachments拒收未知kind。 - 验证矩阵与范围说明(PASS):
- 24 个架构、Chat 与 Lark 定向 pytest 套件:
1630 passed(tests/architecture/*、test_chat_*、test_lark_*、test_audit_cli_and_runtime_fixes.py、test_manager_context_roundtrip.py、test_goal_activation.py全部通过)。 - 真实入口 smoke:
examples/loopx-managed-turn-operator-flow-smoke.py输出 5 项检查ok: true;examples/loopx-steward-managed-chat-smoke.py因本地未安装可选包deepseek-harness-sdk退出0并输出skip: deepseek-harness-sdk is not installed(UNVERIFIED 真实外部 SDK 调用,已由test_chat_dsh_adapter.py与loopx-managed-turn-operator-flow-smoke.py覆盖适配器逻辑)。 - 静态与门禁检查:
ruff check(29 个修改.py文件全通过)、mypy(17 个 strict 文件全通过)、scripts/check_rfc_bilingual.py --base origin/main --head HEAD通过(成对验证harness-selection-dsh-pi-v0EN/ZH)、git diff --check通过、loopx check(32 个文件errors=0)通过、canary premerge在隔离HOME下 6/6 直接检查 + 2/2 目录 canary + 8/8 风险 smoke + 1/1 边界检查全部 PASS(11/11 selected checks, 0 failures)。
- 24 个架构、Chat 与 Lark 定向 pytest 套件:
- 并发与主干推进说明(非阻断):审查期间
origin/main已合入 PR#9193推进至202d7bdb05(零文件重叠,GitHub 状态为MERGEABLE、BEHIND),故canary premerge在最新origin/main下的scope_fingerprint未命中作者先前在db76a91f0c记录的 CQR(cqr_a97ef1e293d78a18e0b2)。另本 PR 与并行 M1 PR#9196均为122 -> 119棘轮,先合入一方后,另一方只需按119 -> 116重演预算与test_chat_internal_module_layout.py/chat_runtime.py的单行 rebase 即可。
我的整体评价 / Verdict
本 PR 为 justified_increment:干净完成对 db76a91f0c 的变基并补齐了 #8905 带来的相对导入对齐与双语 RFC 同步,将 3 个内部 Chat 叶子模块无 shim 归位至 loopx/chat/ 且把顶层预算从 122 准确压低至 119。
- Long-horizon(
improved):loopx/顶层模块降至 119 且由布局测试锁死无 shim 约束,清晰划分内部 Chat 模块边界。 - User experience(
preserved)与 Visual review(not_applicable):本次仅迁移内部 Python 模块与同步 RFC 路径文字,未改动任何 UI 渲染视图(已核对loopx/presentation/configuration_api.py与loopx/presentation/codex_attached_api.py仅修改 import 路径,unverified_scope:none)。 - 语义词表与兼容决策:未新增或改动任何枚举、协议 schema 或行为默认值(
semantic_alignment:not_applicable、compatibility_assessment:not_applicable、observable_semantics:equivalent、default_off_isolation:not_applicable)。 - Exact-head freshness:复核远端
HEAD仍为01bd56d3be528a2b50f8c901fe9407b0681af8c2(OPEN、MERGEABLE、wait_for_ci: false),全部本地定向测试、smoke 与静态校验均已在该精确 head 独立通过。
English verdict: APPROVE at exact head 01bd56d (published as COMMENTED review because PR #9179 is author-owned; cleanly rebased onto db76a91 with dsh._turn_prompt aligned, 3 internal Chat leaf modules moved to loopx/chat/{attachments,dsh,operator_provider_api}.py with zero shims, bilingual RFC refs updated symmetrically, budget ratcheted 122 -> 119, 1630 pytest cases + operator-flow smoke + ruff + mypy + canary premerge 11/11 PASS; optional deepseek-harness-sdk smoke skipped due to uninstalled optional package).
|
This pull request has merge conflicts with Choose the remote for the base repository, not an out-of-date fork. git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEADFor a same-repository clone whose Keep the DCO |
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI (runtime_reported, xhigh)
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
评审固定提交 01bd56d3be528a2b50f8c901fe9407b0681af8c2,merge base db76a91f0cc1afb8b10505a94b0a44cf017aaa69。与核对时 main a6ffb3be6e7bdb48e02311ec58d618200fe0501c 的三方整合在预算清单处有冲突。
[P2 · Blocking] 合并后预算必须钉在 118,当前两个冲突版本均不满足
三方整合只在 top_level_module_budget.json 产生冲突。组合树实测 118 个顶层 Python 文件;采用 main 的 121 或 PR 的 119 均被同一预算测试拒绝。临时仅将组合树的清单重算为 118 后,两份树各 108 项定向测试通过。 在当前 main 上同步或变基,保留 #8934 已有净减后的 121 下限并再减本 PR 的三项,将组合预算钉为 118,保留原 allowlist 和实际测量的基准,提交新精确头。 候选位置 已有 Gemini 评审
动机 / Motivation
M1 将附件、DSH 和 Operator Provider 三个内部 Chat leaf 移至 loopx/chat,保留原调用、HTTP 与运行时,按实际净减少量同步收紧顶层模块预算。 原 PR merge base 还有 122 个顶层模块;当前 main 已因 #8934 去除另一个顶层模块,实测 121、预算 121。 PR 将三个 leaf 无 shim 迁移并把自己分支的预算调为 119。双语 RFC 与调用方同步,现有行为仍由相同的实现提供。
用 Git 三方合成源码枚举包顶层文件,在相同树上逐一将原 main、PR 及修正的精确清单交给现有 ratchet 测试。另在确切源码与临时组合树行使附件、DSH、Operator 凭据和 Lark 消费入口。 组合反例仅在快速本地候选上把一个清单值从冲突改成 118。实际 PR 分支仍有冲突,需作者新 head。真实可选 DSH SDK、生产 Lark 和托管 CI 未验收。环境最初从共享 editable venv 读到了旧文件;排除其导入钩子后重新验证精确树和临时组合树。 现有交付规则
改动思路 / Approach
普通运行和受管入口保持既有语义。没有新默认开关或迁移流程,仍由原 settings、HTTP 和队列入口触发。 三处 owner 的附件验证、DSH 只读片段和 Operator Provider 配置保持现有入口。私有路径的导入调整不改公开 API 或能力权限。 组合需要保留第三方先行落地的净减,并使本轮迁移的三项预算净减持续可回读。
具体改动 / Changes
完整 diff 共 32 个文件,新增 48 行、删除 39 行。32 个文件中只有三处 leaf 重定位、对应 import 与双语文档路径、预算和布局测试。附件文件的源码对象直接复用,另两处实际逻辑未变。
-
M1 归位和 I3 内部边界。迁移三个内部 owner、维护原入口且不留已判定无公共消费者的旧 shim。
-
同 PR 收紧预算。当前主干的 121 再净减三项,组合预算必须等于 118。
-
双语和真实入口核验。同步两份 RFC,原附件、DSH 与控制路由在实际包中可用。
-
max_top_level_modules。固定应与支撑树的实测顶层 Python 文件数相等。 精确代码 -
test_top_level_module_count_stays_at_the_pinned_budget。拒绝大于预算和绕过应有的预算净减。 精确代码 -
normalize_chat_attachments。原附件校验 owner 下移。 精确代码 -
DshChatAdapter。受管 DSH 原单段只读入口。 精确代码 -
OperatorProviderRequestMixin。原设置 API 的凭据读写入口。 精确代码
对主干的风险 / Risks
隔离解释器的精确头与仅调整清单的组合树各 108 项测试通过。原 DSH managed-turn operator flow 各通过五项,双语差异通过。标准 Chat bundle 和 wheel 构建通过,独立环境能导入三个新所有者,旧路径不可导入。
PR merge base 的 122 与当前 main 的 121 均各自在自己的源码树正确;PR head 的 119 也与本分支源一致。合成源码的元素集合与两侧都不同,实际数目为 118。 当前 GitHub 显示 CONFLICTING。现有 Gemini 结论对应同一代码树在旧主干的判断,保留其证据;新的组合条件明确阻塞。
我的整体评价 / Verdict
REQUEST_CHANGES。 请按 118 修复预算清单后回读新精确头。三个 leaf 的代码、隔离运行和安装导入已验证。当前分支与主干合成仍阻塞。
English verdict: REQUEST_CHANGES. The relocation and installed imports pass. Current main yields 118 top-level modules with the three moves, so neither side's conflicting 121 or 119 manifest can pass the exact-count gate.
Goal And Delivered Outcome
docs/architecture/rfcs/monorepo-distribution-split-v0.md(Milestone M1, Invariant I3, and Section 9 top-level module budget ratchet; related to RFC: split LoopX distributions inside the monorepo (loopx-core / loopx-workspace / capability packages) and pin top-level module growth #5072).loopx/chat_operator_provider_api.py,loopx/chat_attachments.py,loopx/chat_dsh.py) still sat at the package top level (122top-level modules onmain), instead of co-locating underloopx/chat/.loopx/held122top-level*.pymodules (tests/architecture/top_level_module_budget.jsonpinned122).loopx/chat/(operator_provider_api.py,attachments.py,dsh.py) with zero top-level compatibility shims, alignedloopx/chat/dsh.pywithloopx.chat._turn_prompt(refactor(chat): move shared turn prompt to loopx.chat, deduplicate chat_agent, and retire ceiling #8905), updated all internal callers/tests/smokes/RFC references, added no-shim assertions intests/test_chat_internal_module_layout.py, and loweredmax_top_level_modulesto119(baseline_commitdb76a91f0cc1afb8b10505a94b0a44cf017aaa69). Proven bytests/architecture/test_top_level_module_budget.py,tests/test_chat_internal_module_layout.py, targeted chat/Lark pytest (340+1290passed), andcanary premerge(11/11selected checks passed).main(rebased ontodb76a91f0cc1afb8b10505a94b0a44cf017aaa69).Author Declaration
Implemented against
docs/architecture/rfcs/monorepo-distribution-split-v0.md(M1,I3, Section 9) atdb76a91f0cc1afb8b10505a94b0a44cf017aaa69loopx/chat/loopx/chat/operator_provider_api.py,loopx/chat/attachments.py,loopx/chat/dsh.pypytest -q --no-cov tests/test_chat_internal_module_layout.pyloopx/presentation/*,loopx/chat/*,loopx/chat_*.py,loopx/extensions/lark/*,loopx/capabilities/native_chat/*,tests/*,examples/*rg -n "chat_operator_provider_api|chat_attachments|chat_dsh"+tests/test_chat_internal_module_layout.pydocs/architecture/rfcs/harness-selection-dsh-pi-v0.md,docs/architecture/rfcs/harness-selection-dsh-pi-v0.zh-CN.mdpython scripts/check_rfc_bilingual.py --base origin/main --head HEADtests/architecture/top_level_module_budget.json(122→119)pytest -q --no-cov tests/architecture/test_top_level_module_budget.pyls -1 loopx/*.py | wc -l==119, confirmed zero stale old-module imports across code/tests/examples/docs viarg, checked bilingual RFC diff, ran focused architecture/Chat/Lark pytest suites, ranruffandmypy, ranloopx checkandloopx canary premerge, and verified Goal-boundchange-qualityreceipt (cqr_a97ef1e293d78a18e0b2).Scope And Continuation
122→119). Broader M1–M5 distribution split and remaining top-level modules stay open under RFC: split LoopX distributions inside the monorepo (loopx-core / loopx-workspace / capability packages) and pin top-level module growth #5072.Validation
01bd56d3be528a2b50f8c901fe9407b0681af8c2(rebased cleanly ontodb76a91f0c;340 + 1290unit pytest,ruff,mypy, smokes, andloopx checkran on identical Python/RFC sourcecdd5be9c6cimmediately prior to updatingbaseline_committodb76a91f0c, followed bytest_top_level_module_budget.py,test_chat_internal_module_layout.py,check_rfc_bilingual.py,change-quality, andcanary premergeon exactHEAD01bd56d3be)finishedsynthetic,public_fixtureunitpassedpytest -q --no-cov tests/architecture/test_top_level_module_budget.py tests/architecture/test_control_plane_import_boundaries.py tests/architecture/test_package_kernel_import_ratchet.py tests/test_chat_image_attachments.py tests/test_chat_image_http.py tests/test_chat_dsh_adapter.py tests/test_chat_endpoint_readiness.py tests/test_chat_executor_profile.py tests/test_atomic_write_modes.py tests/test_chat_reasoning_selection.py tests/control_plane/test_goal_activation.py tests/test_chat_internal_module_layout.py tests/test_audit_cli_and_runtime_fixes.py tests/test_manager_context_roundtrip.py→340 passed in 100.78s; re-rantests/architecture/test_top_level_module_budget.py tests/test_chat_internal_module_layout.pyon01bd56d3be→9 passed in 0.48sunitpassedpytest -q --no-cov tests/test_lark_private_images.py tests/test_lark_app_image_projection.py tests/test_lark_post_images.py tests/test_chat_file_discovery.py tests/test_chat_machine_configuration_api.py tests/test_chat_transport_composition.py tests/test_chat_agent.py tests/test_chat_server_cors.py tests/test_chat_startup_isolation.py tests/test_lark_private_conversations.py→1290 passed in 762.50sreal_entrypointpassedpython examples/loopx-managed-turn-operator-flow-smoke.py(ok: true, all 5 checks passed);examples/loopx-steward-managed-chat-smoke.pyexited0(printedskip: deepseek-harness-sdk is not installedbecause optional SDK is absent in this environment)staticpassedruff checkon 29 touched Python files (All checks passed!);python -m mypy(Success: no issues found in 17 source files);scripts/check_rfc_bilingual.py --base origin/main --head HEAD(RFC bilingual diff check passed.);loopx check --scan-path ...(ok: true,errors: 0,215files)regression_paritypassedloopx canary premerge --from-git-diff --git-diff-base origin/main --format json→ok: true,direct_checks: 6/6,selected_checks: 11/11(catalog_run: 2/2,risk_profile_run: 8/8,boundary_run: 1/1),failure_count: 0,change_quality_qualification.status: valid(cqr_a97ef1e293d78a18e0b2)examples/loopx-steward-managed-chat-smoke.pyskipped live SDK execution (deepseek-harness-sdknot installed), whiletests/test_chat_dsh_adapter.pyandexamples/loopx-managed-turn-operator-flow-smoke.pyexercisedloopx.chat.dsh.DshChatAdapterdirectly.Frontend / Visual Evidence
nonenoneType of Change
LoopX Area
Technical Direction
docs/architecture/rfcs/monorepo-distribution-split-v0.md(M1,I3, Section 9)Shared-authority RFC fixture impact
N/A
Boundary Checklist
.loopx/,.codex/goals/, and liveACTIVE_GOAL_STATE.md).python3 scripts/check_rfc_bilingual.py --base origin/main --head HEADpasses, or no paired RFC changed.none.Signed-off-bytrailer (git commit -s).